﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QDT.Common;
using QDT.Core.Assignments;
using QDT.Core.Deals;
using QDT.Core.Members;
using QDT.Core.Projects;

namespace QDT.Web.Models
{

    public class Img
    {
        public string src { get; set; }
        public string url { get; set; }
    }

    public class ProjectDto
    {
        public ProjectDto(Project project)
        {
            pid = project.ID.ToString();
            pname = project.Name;
            prate = project.Rate.ToString();
            pterm = project.RepayTime.ToString();
            pstatus = project.InnerStatus.ToString();
            pstart = project.StartTime.HasValue ? project.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
            isrealname = "1";
            pmoney = project.BorrowAmount.ToString("0.00");
            pneedmoney = project.NeedMoney.ToString("0.00");
            progress = project.Progress.ToString();
            settleday = project.SettleDay.ToString();
        }
        public string pid { get; set; }
        public string pname { get; set; }
        public string prate { get; set; }
        public string pterm { get; set; }
        public string pstatus { get; set; }
        public string pstart { get; set; }
        public string isrealname { get; set; }
        public string pmoney { get; set; }
        public string pneedmoney { get; set; }
        public string progress { get; set; }
        public string settleday { get; set; }
        public string investcount { get; set; }
    }


    public class AssignDto
    {
        public AssignDto(Assignment assign)
        {
            var days = (assign.Project.RepayEndTime.Value.Date - DateTime.Now.Date).Days;
            pid = assign.ProjectId.ToString();
            aid = assign.ID.ToString();
            pname = assign.Project.Name;
            prate = assign.Project.Rate.ToString();
            aterm = (days < 0 ? 0 : days).ToString();
            astatus = assign.InnerStatus.ToString();
            astart = assign.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
            amoney = assign.Money.ToString("0.00");
            aneedmoney = assign.NeedMoney.ToString("0.00");
            settleday = assign.Project.SettleDay.ToString();
            discount = assign.DiscountRate.ToString();
            buyamount = assign.BuyAmount.ToString("0.00");
        }

        public string pid { get; set; }
        public string aid { get; set; }
        public string pname { get; set; }
        public string prate { get; set; }
        public string aterm { get; set; }
        public string astatus { get; set; }
        public string amoney { get; set; }
        public string aneedmoney { get; set; }
        public string astart { get; set; }
        public string pstart { get; set; }
        public string settleday { get; set; }
        public string discount { get; set; }
        public string buyamount { get; set; }
        public string investcount { get; set; }

    }

    public class InvestRecordDto
    {
        public InvestRecordDto(Credit credit)
        {
            username = credit.UserName.ToConfuse(1, 1, 3);
            money = credit.BuyMoney.ToString("0.00");
            createtime = credit.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
            currentstage = credit.CurrentStage.ToString();
            totalstage = credit.TotalStage.ToString();
            status = credit.Status.ToLocalizable();
        }
        public string username { get; set; }
        public string money { get; set; }
        public string createtime { get; set; }
        public string projectname { get; set; }
        public string currentstage { get; set; }
        public string totalstage { get; set; }
        public string status { get; set; }
    }

    public class UserLogDto
    {
        public UserLogDto(UserTransLog log)
        {
            info = log.Info;
            createtime = log.Time.ToString("yyyy-MM-dd HH:mm:ss");
            money = log.Money.ToString("0.00");
            overmoney = log.OverMoney.ToString("0.00");
            tradeuser = log.TradeUser;
            tradetype = log.Trade.ToLocalizable();
        }
        public string info { get; set; }
        public string createtime { get; set; }
        public string money { get; set; }
        public string overmoney { get; set; }
        public string tradeuser { get; set; }
        public string tradetype { get; set; }
    }

    public class UserDto
    {
        public UserDto(User user)
        {
            id = user.ID.ToString();
            username = user.UserName;
            email = user.EmailPassed ? user.Email : "";
            mobile = user.MobilePassed ? user.Mobile : "";
            realname = user.IDCardPassed ? user.RealName : "";
            idcard = user.IDCardPassed ? user.IDCard : "";
        }
        public string id { get; set; }
        public string username { get; set; }
        public string email { get; set; }
        public string realname { get; set; }
        public string idcard { get; set; }
        public string mobile { get; set; }
    }

    public class AppLoginModel
    {
        public string username { get; set; }
        public string password { get; set; }
    }

    public class AppRegisterModel
    {
        public string username { get; set; }
        public string mobile { get; set; }
        public string password { get; set; }
        public string confirmpassword { get; set; }
        public string token { get; set; }
    }

    public class UserAccountDto
    {
        public UserAccountDto(User user)
        {
            money = user.UserAccount.Money.ToString("0.00");
            lockmoney = user.UserAccount.LockMoney.ToString("0.00");
            loadearnings = user.UserSta.LoadEarnings.ToString("0.00");
            loadwaitrepaymoney = user.UserSta.LoadWaitRepayMoney.ToString("0.00");
            loadwaitrepayearnings = user.UserSta.LoadWaitRepayEarnings.ToString("0.00");
            totalassets =
                (user.UserAccount.Money + user.UserAccount.LockMoney + user.UserSta.LoadWaitRepayMoney +
                 user.UserSta.LoadWaitRepayEarnings).ToString("0.00");
        }
        public string money { get; set; }
        public string lockmoney { get; set; }
        public string loadearnings { get; set; }
        public string loadwaitrepaymoney { get; set; }
        public string loadwaitrepayearnings { get; set; }
        public string totalassets { get; set; }
        public string investcount { get; set; }
    }

    public class UserQueryModel
    {
        public int id { get; set; }
        public string token { get; set; }
    }

    public class SendSmsModel
    {
        public string mobile { get; set; }
        public string token { get; set; }
        public string type { get; set; }
    }

    public class SendEmailModel
    {
        public string email { get; set; }
        public string token { get; set; }
        public string type { get; set; }
    }

    public class BindEmailModel
    {
        public int id { get; set; }
        public string email { get; set; }
        public string token { get; set; }
    }

    public class BindMobileModel
    {
        public int id { get; set; }
        public string mobile { get; set; }
        public string token { get; set; }
    }

    public class BindIdCardModel
    {
        public int id { get; set; }
        public string idcard { get; set; }
        public string realname { get; set; }
        public string token { get; set; }
    }

    public class ChangePasswordModel
    {
        public int id { get; set; }
        public string mobile { get; set; }
        public string password { get; set; }
        public string newpassword { get; set; }
        public string confirmpassword { get; set; }
        public string token { get; set; }
    }

    public class InvestProjectModel
    {
        public int userid { get; set; }
        public int projectid { get; set; }
        public decimal money { get; set; }
        public int client { get; set; }
        public string token { get; set; }
    }

    public class InvestAssignModel
    {
        public int userid { get; set; }
        public int assignid { get; set; }
        public decimal money { get; set; }
        public int client { get; set; }
        public string token { get; set; }
    }

}